#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>
#include<stdlib.h>

int main()
{
	int max = 0;
	int n, c;
	scanf("%d %d", &n, &c);
	int* nums = malloc(n * sizeof(int));
	int i = 0;
	while (i < n && scanf("%d", &nums[i]) == 1)
		i++;

	int cacharmax = 0;
	for (i = 0; i < n; i++)
	{
		for (int j = i; j < n; j++)
		{
			cacharmax += nums[j];
			if (cacharmax == c)
			{
				printf("max=%d", cacharmax);
				return 0;
			}
			else if (cacharmax < c)
			{
				if (cacharmax > max)
				{
					max = cacharmax;
				}
			}
			else
				cacharmax = 0;
		}
	}
	printf("max=%d", max);
	free(nums);
	nums = NULL;
	return 0;
}